import State from "../../../Base/State";
import { StateMachine } from "../../../Base/StateMachine";
import { DIRECTION_ENUM, SHAKE_TYPE_ENUM } from "../../../Enums";
import DirectionSubStateMachine from "../../../Base/DirectionSubStateMachine";
import { AnimationClip } from "cc";
import { ANIMATION_SPEED } from "../../../utils/constant";

const BASE_PATH = 'texture/player/attack'

export default class AttackSubStateMachine extends DirectionSubStateMachine {

  constructor(fsm: StateMachine) {
    super(fsm)
    this.stateMachines.set(
      DIRECTION_ENUM.UP,
      new State(fsm,`${BASE_PATH}/top`,AnimationClip.WrapMode.Normal,ANIMATION_SPEED,[{
        frame: ANIMATION_SPEED * 4,  // 第五帧
        func: 'onAttackShake',  // 回调函数名称，在PlayerManager中定义
        params: [SHAKE_TYPE_ENUM.UP] // 回调函数参数
      }]))
    this.stateMachines.set(
      DIRECTION_ENUM.DOWN,
      new State(fsm,`${BASE_PATH}/bottom`,AnimationClip.WrapMode.Normal,ANIMATION_SPEED,[{
        frame: ANIMATION_SPEED * 4,
        func: 'onAttackShake',
        params: [SHAKE_TYPE_ENUM.DOWN]
      }]))
    this.stateMachines.set(
      DIRECTION_ENUM.LEFT,
      new State(fsm,`${BASE_PATH}/left`,AnimationClip.WrapMode.Normal,ANIMATION_SPEED,[{
        frame: ANIMATION_SPEED * 4,
        func: 'onAttackShake',
        params: [SHAKE_TYPE_ENUM.LEFT]
      }])
    )
    this.stateMachines.set(
      DIRECTION_ENUM.RIGHT,
      new State(fsm,`${BASE_PATH}/right`,AnimationClip.WrapMode.Normal,ANIMATION_SPEED,[{
        frame: ANIMATION_SPEED * 4,
        func: 'onAttackShake',
        params: [SHAKE_TYPE_ENUM.RIGHT]
      }])
    )
  }
}
